#!/usr/bin/env python

import sys
import itertools

from kegg import get_server

def ChunkIter( iterable, chunk_size ):
    iterator = iter( iterable )
    while 1:
        chunk = list( itertools.islice( iterator, chunk_size ) )
        if not len( chunk ): break
        yield chunk


def main():
    server  = get_server()
    for chunk in ChunkIter(sys.stdin, 1000):
        for res in server.bconv(" ".join("ncbi-geneid:%s" % l.strip() for l in chunk)).split('\n'):
            if res:
                ncbi_id, kegg_id, status = res.split('\t')
                print "%s\t%s\t%s" % (ncbi_id.split(':')[1], kegg_id, status)


if __name__ == '__main__':
    main()

